package reamodel.diagram.edit.policies;

import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.commands.Command;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.emf.commands.core.commands.DuplicateEObjectsCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;

import reamodel.ReamodelPackage;
import reamodel.diagram.edit.commands.DecrementCommitmentCreateCommand;
import reamodel.diagram.edit.commands.DecrementEconomicEventCreateCommand;
import reamodel.diagram.edit.commands.DecrementEconomicEventTypeCreateCommand;
import reamodel.diagram.edit.commands.EconomicAgentCreateCommand;
import reamodel.diagram.edit.commands.EconomicAgentTypeCreateCommand;
import reamodel.diagram.edit.commands.EconomicResourceCreateCommand;
import reamodel.diagram.edit.commands.EconomicResourceTypeCreateCommand;
import reamodel.diagram.edit.commands.IncrementCommitmentCreateCommand;
import reamodel.diagram.edit.commands.IncrementEconomicEventCreateCommand;
import reamodel.diagram.edit.commands.IncrementEconomicEventTypeCreateCommand;
import reamodel.diagram.providers.REAmetamodelElementTypes;

/**
 * @generated
 */
public class REAModelItemSemanticEditPolicy extends
		REAmetamodelBaseItemSemanticEditPolicy {

	/**
	 * @generated
	 */
	protected Command getCreateCommand(CreateElementRequest req) {
		if (REAmetamodelElementTypes.EconomicResourceType_1001 == req
				.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(ReamodelPackage.eINSTANCE
						.getREAModel_ResourceTypes());
			}
			return getGEFWrapper(new EconomicResourceTypeCreateCommand(req));
		}
		if (REAmetamodelElementTypes.EconomicAgentType_1002 == req
				.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(ReamodelPackage.eINSTANCE
						.getREAModel_AgentTypes());
			}
			return getGEFWrapper(new EconomicAgentTypeCreateCommand(req));
		}
		if (REAmetamodelElementTypes.DecrementEconomicEventType_1003 == req
				.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(ReamodelPackage.eINSTANCE
						.getREAModel_EventTypes());
			}
			return getGEFWrapper(new DecrementEconomicEventTypeCreateCommand(
					req));
		}
		if (REAmetamodelElementTypes.IncrementEconomicEventType_1004 == req
				.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(ReamodelPackage.eINSTANCE
						.getREAModel_EventTypes());
			}
			return getGEFWrapper(new IncrementEconomicEventTypeCreateCommand(
					req));
		}
		if (REAmetamodelElementTypes.EconomicAgent_1005 == req.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(ReamodelPackage.eINSTANCE
						.getREAModel_Agents());
			}
			return getGEFWrapper(new EconomicAgentCreateCommand(req));
		}
		if (REAmetamodelElementTypes.EconomicResource_1006 == req
				.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(ReamodelPackage.eINSTANCE
						.getREAModel_Resources());
			}
			return getGEFWrapper(new EconomicResourceCreateCommand(req));
		}
		if (REAmetamodelElementTypes.DecrementEconomicEvent_1007 == req
				.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(ReamodelPackage.eINSTANCE
						.getREAModel_Events());
			}
			return getGEFWrapper(new DecrementEconomicEventCreateCommand(req));
		}
		if (REAmetamodelElementTypes.IncrementEconomicEvent_1008 == req
				.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(ReamodelPackage.eINSTANCE
						.getREAModel_Events());
			}
			return getGEFWrapper(new IncrementEconomicEventCreateCommand(req));
		}
		if (REAmetamodelElementTypes.IncrementCommitment_1009 == req
				.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(ReamodelPackage.eINSTANCE
						.getREAModel_Commitments());
			}
			return getGEFWrapper(new IncrementCommitmentCreateCommand(req));
		}
		if (REAmetamodelElementTypes.DecrementCommitment_1010 == req
				.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(ReamodelPackage.eINSTANCE
						.getREAModel_Commitments());
			}
			return getGEFWrapper(new DecrementCommitmentCreateCommand(req));
		}
		return super.getCreateCommand(req);
	}

	/**
	 * @generated
	 */
	protected Command getDuplicateCommand(DuplicateElementsRequest req) {
		TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
				.getEditingDomain();
		return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req));
	}

	/**
	 * @generated
	 */
	private static class DuplicateAnythingCommand extends
			DuplicateEObjectsCommand {

		/**
		 * @generated
		 */
		public DuplicateAnythingCommand(
				TransactionalEditingDomain editingDomain,
				DuplicateElementsRequest req) {
			super(editingDomain, req.getLabel(), req
					.getElementsToBeDuplicated(), req
					.getAllDuplicatedElementsMap());
		}

	}

}
